package com.central.dataManage.mapper;

import com.central.common.model.TableInfo;
import com.central.db.mapper.SuperMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Tindy
 * @date 2021/7/5
 * @describe
 */
@Mapper
public interface TableInfoMapper extends SuperMapper<TableInfo> {
    @Select("select t.id,t.table_name from table_info t inner join pro_table_privilege ptp on t.datasource_id=ptp.datasource_id and t.db_name=ptp.db_name and t.table_name=ptp.table_name  where t.database_id=#{databaseId} and ptp.pro_id=#{proId}")
    List<TableInfo> findProTables(@Param("proId") Long proId,@Param("databaseId") Long databaseId);

    @Select("select t.id,t.table_name from table_info t inner join user_table_privilege ptp on t.datasource_id=ptp.datasource_id and t.db_name=ptp.db_name and t.table_name=ptp.table_name  where t.database_id=190 and ptp.pro_id=2 and ptp.user_id=44")
    List<TableInfo> findProUserTables(@Param("userId")Long userId,@Param("proId") Long proId,@Param("databaseId") Long databaseId);
}
